import java.util.Deque;
import java.util.concurrent.LinkedBlockingDeque;
class Zcsh {
    public int maxProduct(int[] nums) {
        int maxValue = Integer.MIN_VALUE;
        int currentMax = 1;
        int currentMin = 1;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] < 0) {
                int temp = currentMax;
                currentMax = currentMin;
                currentMin = temp;
            }
            currentMax = Math.max(nums[i] * currentMax, nums[i]);
            currentMin = Math.min(nums[i] * currentMin, nums[i]);
            maxValue = Math.max(maxValue, currentMax);
        }
        return maxValue;
    }

}